Skip to main content

Animation Frustum Culling

Animation calculation can be disabled for the entities whose renderers are not visible to the camera. Rukhanka Animation has advanced capabilities to cull animations with respect to:

  • Multiple cameras and their respective frustum volumes to determine object visibility.
  • Shadow-casting lights and their respective shadow-casting volumes for renderers shadow visibility determination.

The animation culling configuration consists of two steps: culling environment setup, and per-entity culling preferences configuration.

Animation Culling Environment Setup

Rukhanka must know which relevant scene objects (Cameras and Lights) it must use for visibility determination. For this purpose, a special script AnimationCullingConfig should be used:

Animation Culling Config

This is an ordinary MonoBehaviour Component that must reside on the same scene as required culling Cameras and Lights.

warning

AnimationCullingConfig should not be placed in the entities subscene because it will be destroyed during the baking process

  • The Culling Cameras array should contain all Unity's Cameras used for object visibility determination.
  • Shadow Casting Lights is an array of shadow-casting Lights which shadows should be properly accounted for during object visibility determination.
  • The Add Editor Scene Camera checkbox is used for adding an editor scene camera to the Culling Cameras list.
  • The Debug And Visualization dropdown contains visualization options for object visibility debugging.

Animated Entity Culling Setup

Animation culling can be configured on a per-object basis.

Unity's Animator Culling Mode property controls Rukhanka's animation culling functionality:

Animator Culling Mode

There are two options available:

  • Always Animate option - do not use animation culling for this entity. Animations will be calculated regardless of visibility.
  • Cull Update Transforms and Cull Completely options have the same meaning - stop animation calculation for entities invisible (and their shadows invisible also) for cameras defined in AnimationCullingConfig Culling Cameras array.
info

Note that Root Motion, User Curves, and Animation Events are still processed even for invisible entities.

IMPORTANT

Rukhanka runtime will produce an error if Animator Culling Mode is configured to cull animations but Animation Culling Config is absent on scene.

Animation Culling Visualization

With RUKHANKA_DEBUG_INFO defined AnimationCullingConfig additional Debug And Visualization options become available.

Animation Culling Config Visualization Options

  • With Draw Culling Volumes checkbox culling volumes are rendered with Culling Volume Color.
  • Draw Scene Bounding Boxes checkbox controls visualization of chunk and individual renderers bounding boxes with appropriate colors:
    • Visible Chunk Color is used for visible chunks bounding box rendering.
    • Invisible Chunk Color is used for invisible chunks.
    • Visible Renderer Color is used for visible renderers bounding box drawings.
    • Invisible Renderer Color is used for invisible renderers.

Bounding Box Rendering